package com.feiyu.common.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.feiyu.common.utils.PageUtils;
import com.feiyu.common.utils.Query;

import com.feiyu.common.dao.AddressDao;
import com.feiyu.common.entity.AddressEntity;
import com.feiyu.common.service.AddressService;


@Service("addressService")
public class AddressServiceImpl extends ServiceImpl<AddressDao, AddressEntity> implements AddressService {
    @Autowired
    AddressDao addressDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AddressEntity> page = this.page(
                new Query<AddressEntity>().getPage(params),
                new QueryWrapper<AddressEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPageByMyself(Map<String, Object> params) {
        QueryWrapper<AddressEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",params.get("userId"));
        IPage<AddressEntity> page = this.page(
                new Query<AddressEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

//    @Override
//    public List<AddressEntity> getAllByUserId(Integer userId) {
//        List<AddressEntity> allByUserId = addressDao.getAllByUserId(userId);
//        return allByUserId;
//    }

}